package TCP.UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Server {
    public static void main(String[] args) throws Exception {
        //创建一个空包（必须先有空包）
        byte[] b = new byte[1024];
        DatagramPacket dp = new DatagramPacket(b,b.length);

        //接收
        DatagramSocket ds = new DatagramSocket(8888);
        System.out.println("服务器启动成功~");
        ds.receive(dp);
        //接收完之后dp就有内容了
        System.out.println("客户端"+dp.getSocketAddress()+"说：");
        System.out.println(new String(dp.getData(),0,dp.getLength()));

    }
}
